package com.zqxq.lottery.controller.user;

import com.baomidou.mybatisplus.plugins.Page;
import com.zqxq.common.constant.Result;
import com.zqxq.lottery.entity.bo.user.UserMsgBO;
import com.zqxq.lottery.entity.vo.user.UserMsgVO;
import com.zqxq.lottery.service.user.IUserMsgService;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 说    明：   用户消息
 * 创 建 人：	一刀·胡
 * 创建时间：	2018/6/6 17:26
 * 修 改 人：
 * 修改日期：
 **/
@RestController
@Slf4j
public class UserMsgController extends UserBaseController{

    @Autowired
    private IUserMsgService userMsgService;

    @ApiOperation("获取分页信息")
    @RequestMapping(value="/msg/page", method = RequestMethod.POST)
    public Result<Page<UserMsgVO>> queryUserMsgPage(@RequestBody UserMsgBO search){
        Result<Page<UserMsgVO>> result = new Result<>();
        try {
            Page<UserMsgVO> page = userMsgService.queryPageList(search);
            result.setData(page);
        }catch (Exception e) {
            log.error("QueryUserMsgPage is error!", e);
        }
        return result;
    }

    @ApiOperation("是否有新消息")
    @RequestMapping(value="/msg/new", method = RequestMethod.POST)
    public Result queryUserMsgNew(@RequestParam("userId") String userId){
        Result result = new Result<>();
        try {
            int count = userMsgService.queryUserMsgNew(userId);
            result.setData(count);
        }catch (Exception e) {
            log.error("queryUserMsgNew is error!", e);
        }
        return result;
    }


}
